﻿using CommLibrary.Http.HttpHelperNamespace;
using Model;
using Newtonsoft.Json;

namespace Business
{
    public class AuthorityBll
    {

        public OperateResult Login(LoginInput loginInput, string databaseName)
        {
            return Post(databaseName, loginInput, "Authority/Login");
        }

        private OperateResult Post(string databaseName, object data, string url)
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("databaseName", databaseName);
            HttpHelper httpHelper = new HttpHelper();
            var res = httpHelper.PostAsync($"http://10.123.235.80:7226/api/{url}", JsonConvert.SerializeObject(data), dic).Result;
            if (!string.IsNullOrEmpty(res))
            {
                return JsonConvert.DeserializeObject<OperateResult>(res);
            }
            return new OperateResult() { Message = "请求失败" };
        }
    }
}
